<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    
    <title>Form Layouts</title>
    <link href="/public/js/summernote/dist/summernote.css" rel="stylesheet">
    <!--multi-select-->
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-multi-select/css/multi-select.css" />
    <!--tags input-->
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-tags-input/jquery.tagsinput.css" />
    <script language="javascript">
        function RunOnBeforeUnload() {window.onbeforeunload = function(){ return ""; } }
    </script>
    <?php $this->load->view('library/header');?>
</head>

<body onload="RunOnBeforeUnload()" class="sticky-header">

<?php $this->load->view('library/left');?>

<!-- main content start-->
<div class="main-content" >
    
    <?php $this->load->view('library/top');?>
    
    <!-- page heading start-->
    <div class="page-heading">
        <h3>
            添加商品
        </h3>
        <ul class="breadcrumb">
            <li>
                <a href="#">Forms</a>
            </li>
            <li class="active"> Forms Layouts </li>
        </ul>
    </div>
    <!-- page heading end-->
    
    <!--body wrapper start-->
    <section class="wrapper">
        <div class="row">
            <div class="col-md-12">
                <!-- page start-->
                <section class="panel">
                    <header class="panel-heading custom-tab turquoise-tab">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="#home2" data-toggle="tab">站点信息</a>
                            </li>
                        </ul>
                    </header>
                    <form id="commentForm" class="form-horizontal adminex-form" method="post">
                        <div class="panel-body">
                            <div class="tab-content">
                                <div class="tab-pane active" id="home2">
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">A站</label>
                                        <div class="col-lg-10">
                                            <select class=" form-control" name="web_a" style="float: left;width: 150px;">
                                                <option value="0">选择站点</option>
                                                <?php foreach($siteweb as $k => $v){?>
                                                    <option value="<?php echo $v['web_id']?>"><?php echo $v['web_name']?></option>
                                                <?php }?>
                                            </select>
                                            <button class="btn btn-info page" type="submit" style="float: left;">获取页数</button>
                                            
                                            <input type="text" name="web_page" readonly style="height: 33px;width: 50px;margin-left:50px;">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">B站</label>
                                        <div class="col-lg-10">
                                            <select class=" form-control" name="web_b" style="float: left;width: 150px;">
                                                <option value="0">选择站点</option>
                                                <?php foreach($siteweb as $k => $v){?>
                                                    <option value="<?php echo $v['web_id']?>"><?php echo $v['web_name']?></option>
                                                <?php }?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="com"></div>
                                
                            </div>
                        </div>
                        <button type="submit" name="handle_type" value="0" class="btn btn-post pull-right btn-big">拉取数据</button>
                    </form>
                </section>
                <!-- page end-->
            </div>
        </div>
    </section>
    <!--body wrapper end-->
    
    <!--footer section start-->
    <footer>
        2014 &copy; AdminEx by
    </footer>
    <!--footer section end-->


</div>
<!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<!--编辑器-->

<!--multi-select-->
<script type="text/javascript" src="/public/js/jquery-multi-select/js/jquery.multi-select.js"></script>
<script type="text/javascript" src="/public/js/jquery-multi-select/js/jquery.quicksearch.js"></script>
<script src="/public/js/multi-select-init.js"></script>

<!--tags input-->
<script src="/public/js/jquery-tags-input/jquery.tagsinput.js"></script>
<script src="/public/js/tagsinput-init.js"></script>

<script src="/public/js/nestable/jquery.nestable.js"></script>
<script src="/public/js/nestable-init.js"></script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

<script>
    $('.page').click(function(){
        var web_a=$("select[name = 'web_a']").val();
        if(web_a == 0){
            alert('选择站点');
        }
        $.ajax({
            type:'post',
            url:"<?php echo base_url('siteweb/shopify_page');?>",
            data:{
                web_a:web_a,
            },
            success:function(msg){
                $("input[name='web_page']").val(msg);
            }
        })
        return false;
    })
        
       


        $('#commentForm').submit(function () {

            t = setTimeout(function() {
                $('.panel-footer .btn-big').attr('disabled','disabled').addClass('btn-submit-disabled').html('正在提交，请稍等...');
            }, 200);

            var data = new FormData(this);
            $("#cate option:not(:selected)").each(function (i) {
                var val = $(this).attr('value');
                if (val) {
                    data.append("cate[]", val);
                }
            });
            swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
            
            $.ajax({
                type: 'POST',
                url: '<?php echo base_url('siteweb/siteweb_copy');?>',
                data: data,
                success: function (data) {
                    clearTimeout(t);
                    if (data.status != 'success') {
                        swal({
                            title: data.info,
                            text: '4秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: 3000,
                            showConfirmButton: false
                        }).then(function(isConfirm) {
                            window.onbeforeunload = '';
                            window.location.href = '<?php echo base_url('siteweb/siteweb_copy');?>';
                        });
                        $('.panel-footer .btn-big').attr("disabled",false).removeClass('btn-submit-disabled').html('提交信息');
                    } else {

                        swal({
                            title: data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: data.stop ? data.stop : 1500,
                            showConfirmButton: false
                        })
                        $('.panel-footer .btn-big').removeClass('btn-submit-disabled').html(data.info);
                    }

                },
                dataType:'json',
                cache: false,
                contentType: false,
                processData: false
            });

            return false;
        });
</script>

</body>
</html>
